//
//  NSString+Addition.m
//  RecruitmentPer
//
//  Created by dfws on 16/9/21.
//  Copyright © 2016年 dfws. All rights reserved.
//

#import "NSString+Addition.h"

@implementation NSString (Addition)

- (float)getStringHeightWithfontSize:(int)size
{
    CGRect rect = [self boundingRectWithSize:CGSizeMake(180, MAXFLOAT)
                                     options:NSStringDrawingUsesLineFragmentOrigin
                                  attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:size]}
                                     context:nil];
    // 向上取整
    return ceilf(rect.size.height);
}

- (CGSize)sizeWithFonts:(UIFont *)font
               maxSizes:(CGSize)maxSize
{
    NSDictionary *attrs = @{NSFontAttributeName : font};
    return [self boundingRectWithSize:maxSize
                              options:NSStringDrawingUsesLineFragmentOrigin
                           attributes:attrs
                              context:nil].size;
}

@end
